package com.zhouwj.utils.FileUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by SilverKnife on 2016/12/8.
 */

public class FileUtils {
    public static JSONObject getAssetsJsonData(String fileName) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            InputStream file = new FileInputStream(fileName);
            BufferedReader bf = new BufferedReader(new InputStreamReader(file));
            String line;
            while ((line = bf.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONObject response = null;
        try {
            response = new JSONObject(stringBuilder.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return response;
    }
}
